import config from "@/constants/config";
import { IDeptTreeSelectItem } from "@/types/system/IDeptTreeSelectItem";
import { IDictResListItem } from "@/types/system/IDictResListItem";
import { ISystemUserListItem } from "@/types/system/ISystemUserListItem";
import { TApiListRequest, TRequest } from "./Modules/HttpRequest";
import { $http } from "./Modules";
import { IUserRouteListItem } from "@/types/system/IUserRouteListItem";


/**
 * 获取部门树选择器
 * @param params
 * @returns
 */
export const reqGetDeptTreeSelect = <T>(params?: T): TRequest<IDeptTreeSelectItem[]> => {
    return new Promise(async (resolve) => {
        const url = "/system/dept/treeselect";
        let result = await $http.get(url, params);
        resolve(result);
    });
};
/**
 * 获取用户列表分页
 * @param params
 * @returns
 */
export const reqGetUserListPage = <T>(params?: T): TApiListRequest<ISystemUserListItem> => {
    return new Promise(async (resolve) => {
        const url = "/system/user/list";
        let result = await $http.get(url, params);
        resolve(result);
    });
};
/**
 * 更改用户状态
 * @param params
 * @returns
 */
export const reqChangeUserStatus = <T>(params?: T): TRequest<boolean> => {
    return new Promise(async (resolve) => {
        const url = "/system/user/changeStatus";
        let result = await $http.put(url, params);
        resolve(result);
    });
};

/**
 * 获取字典
 * @param params
 * @returns
 */
export const reqGetDict = <T>(dictName: string, params?: T): TRequest<IDictResListItem[]> => {
    return new Promise(async (resolve) => {
        const url = `/system/dict/data/type/${dictName}`;
        let result = await $http.get(url, params);
        resolve(result);
    });
};

/**
 * 获取菜单
 * @param params
 * @returns
 */
export const reqGetRoutes = <T>(params?: T): TRequest<IUserRouteListItem[]> => {
    return new Promise(async (resolve) => {
        const url = `/getRouters`;
        let result = await $http.get(url, params);
        resolve(result);
    });
};

